package com.xyy.saas.payment.dao.mapper;

import com.xyy.saas.payment.dao.model.PayResultOrder;
import com.xyy.saas.payment.dto.PayResultOrderAmountDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

@Mapper
public interface PayResultOrderMapper {
    int deleteByPrimaryKey(Long id);

    int insert(PayResultOrder record);

    int insertSelective(PayResultOrder record);

    PayResultOrder selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(PayResultOrder record);

    int updateByPrimaryKey(PayResultOrder record);

    PayResultOrder selectByPayNoAndChannel(@Param("payNo") String payNo, @Param("payChannel") String payChannel);

    PayResultOrder selectByChannelChargeNo(@Param("channelChargeNo") String channelChargeNo);

    PayResultOrder selectByChannelTransactionNo(@Param("channelTransactionNo") String channelTransactionNo);

    List<PayResultOrder> queryByChannelTransactionNo(@Param("list")List<String> list);

    List<PayResultOrder> queryNoneRoyaltyList(@Param("beginTime") LocalDateTime beginTime, @Param("endTime")LocalDateTime endTime);

    List<PayResultOrder> queryPinganCreditListByTime(@Param("beginTime") LocalDateTime beginTime, @Param("endTime")LocalDateTime endTime);

    int testUpdateMerchantId(String payNo);

    int updateRefundStatusById(@Param("id") Long id, @Param("utime") Date utime);

    int updateRoyaltyStatusById(@Param("id") Long id, @Param("utime") Date utime);

    List<PayResultOrder> selectByPayNo(@Param("payNo") String payNo);

    List<PayResultOrder> selectByPayNos(@Param("payNos") List<String> payNos);

    List<PayResultOrder> selectPayResultOrderListByCondition(@Param("payNo") String payNo, @Param("businessOrderType")String businessOrderType,
                                                             @Param("payer") String payer,  @Param("channelTransactionNo")String channelTransactionNo,
                                                             @Param("payChannel") String payChannel,
                                                             @Param("beginTime") Date beginTime, @Param("endTime") Date endTime,
                                                             @Param("page")int page,  @Param("pageSize")int pageSize);

    int selectPayResultOrderCountByCondition(@Param("payNo") String payNo, @Param("businessOrderType")String businessOrderType,
                                                             @Param("payer") String payer,  @Param("channelTransactionNo")String channelTransactionNo,
                                                             @Param("payChannel") String payChannel,
                                                             @Param("beginTime") Date beginTime, @Param("endTime") Date endTime);
    List<PayResultOrder> sumAmountByOrderType(@Param("businessOrderType") String businessOrderType,@Param("payChannel") String payChannel, @Param("startTime") Date startTime, @Param("endTime") Date endTime);

    List<PayResultOrder> countAmountByParamGroup(@Param("payResultOrder") PayResultOrder payResultOrder,
                                                    @Param("startTime") Date startTime, @Param("endTime") Date endTime);

    List<PayResultOrderAmountDTO> countAmountByBusinessOrderType(@Param("businessOrderTypes") List<String> businessOrderTypes, @Param("startTime") Date startTime, @Param("endTime") Date endTime);

    List<PayResultOrder> queryByIdLimit(@Param("payChannel") String payChannel, @Param("startId") Long startId, @Param("endId") Long endId, @Param("limit") int limit);

    List<PayResultOrder> queryPayResultOrderSingleSide1(@Param("beginTime") LocalDateTime beginTime, @Param("endTime") LocalDateTime endTime,
                                                        @Param("payChannels") List<String> payChannels, @Param("tradeCodes") List<Integer> tradeCodes,
                                                        @Param("excludeAccountIds") List<String> tradeCheckExcludeAccountIds);

    List<PayResultOrder> queryPayResultOrderSingleSide2(@Param("beginTime") LocalDateTime beginTime, @Param("endTime") LocalDateTime endTime,
                                                        @Param("payChannels") List<String> payChannels, @Param("tradeCodes") List<Integer> tradeCodes,
                                                        @Param("excludeAccountIds") List<String> tradeCheckExcludeAccountIds);

    List<PayResultOrder> findJdChannelSingleSideTrade(@Param("beginTime") LocalDateTime beginTime, @Param("endTime") LocalDateTime endTime);
}